package com.bruce.ssm.controller;


import com.bruce.ssm.base.BaseController;
import com.bruce.ssm.entity.User;
import com.bruce.ssm.model.ReturnObject;
import com.bruce.ssm.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = "/user", produces = {"application/json;charset=UTF-8"})
public class UserController extends BaseController {
    @Autowired
    private UserService iUserService;

    @RequestMapping(value = "/addUser", method = RequestMethod.POST)
    @ResponseBody
    public ReturnObject addUser(User user) {
        return iUserService.addUser(user);
    }

    @RequestMapping(value = "/deleteUser", method = RequestMethod.GET)
    @ResponseBody()
    public ReturnObject deleteUser(String userId) {
        return iUserService.deleteUser(userId);
    }

    @RequestMapping(value = "/updateUser", method = RequestMethod.POST)
    @ResponseBody
    public ReturnObject updateUser(User user) {
        return iUserService.updateUser(user);
    }

    @RequestMapping(value = "/getAllUser")
    @ResponseBody
    public ReturnObject getAllUser() {
        return iUserService.getAllUser();
    }

    @RequestMapping(value = "/getUserById")
    @ResponseBody
    public ReturnObject getUserById(String userId) {
        return iUserService.getUserById(userId);
    }

}
